//增删改查
import {
    commentModal
} from "../Model/commentModal.js"

export const addComDao = async (obj) => {
    return await commentModal.create(obj)
}

export const delComDao = async (id) => {
    return await commentModal.findByIdAndDelete(id)
}

export const updateComDao = async (id, obj) => {
    return await commentModal.findByIdAndUpdate(id, obj)
}

//获得所有评论
export const getComByPageDao = async (page, size) => {
    const list = await commentModal.find().skip((page - 1) * size).limit(size);
    const total = await commentModal.find().countDocuments()
    return {
        list,total
    }
}

export const getComByIdsByPageDao = async(ids,page,size)=>{
    const list =await commentModal.find({ids}).skip((page-1)*size).limit(size)
    const total = await commentModal.find({ids}).countDocuments()
    return {
        list,total
    }
}